import os, sys, Image
from distutils.dir_util import mkpath

if len(sys.argv) != 3:
	print('Usage: %s <image_file> <android_project_dir>' % sys.argv[0])
	sys.exit(1)

SIZES = [
	('ldpi', 36),
	('mdpi', 48),
	('hdpi', 72),
	('xhdpi', 96)
]

src = Image.open(sys.argv[1])

for size in SIZES:
	drawableDir = os.path.join(sys.argv[2], 'res', 'drawables-%s' % size[0])
	mkpath(drawableDir)
	
	scaled = src.resize((size[1], size[1]), Image.ANTIALIAS)
	scaled.save(os.path.join(drawableDir, 'icon.png'))
